<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:insert="~{include :: header('入驻详情')}" />
    <th:block th:insert="~{include :: select2-css}" />
    <th:block th:insert="~{include :: summernote-css}" />
</head>
<body class="hold-transition">
<div class="container-fluid mt-2 mb-2">
    <form id="form-user-add" class="form-horizontal" th:object="${book}">
        <br>
        <div class="form-group row">
            <label class="col-sm-2 text-sm-right col-form-label">书名:</label>
            <span class="col-sm-8 col-form-label" th:text="*{title}"></span>
        </div>
        <div class="form-group row">
            <label class="col-sm-2 text-sm-right col-form-label">出版社:</label>
            <span class="col-sm-3 col-form-label" th:text="*{publisher}"></span>
            <label class="col-sm-2 text-sm-right col-form-label">类别:</label>
            <span class="col-sm-4 col-form-label" th:text="*{categoryName}"></span>
        </div>
        <div class="form-group row">
            <label class="col-sm-2 text-sm-right col-form-label">主编:</label>
            <span style="margin-right: 10px" th:each="teacher : ${teachers}" class="col-sm-3 col-form-label" th:text="${teacher.name}"></span>
            <label class="col-sm-2 text-sm-right col-form-label">频道:</label>
            <span class="col-sm-4 col-form-label" th:text="${channel.channelName}"></span>
        </div>
        <div class="form-group row">
            <label class="col-sm-2 text-sm-right col-form-label">售价:</label>
            <span style="color: #DD1144;line-height: 38px;" th:text="*{price/100} + '元  '"></span>
            <span style="margin-left: 10px;line-height: 38px;"><del th:text=" *{sourcePrice/100}+元"></del></span>
        </div>
        <div class="form-group row">
            <label class="col-sm-2 text-sm-right col-form-label">创建人:</label>
            <span class="col-sm-3 col-form-label" th:text="${book.userName}"></span>
            <label class="col-sm-2 text-sm-right col-form-label">创建时间:</label>
            <span class="col-sm-3 col-form-label" th:text="${#strings.replace(book.createTime,'T',' ')}"></span>
        </div>
        <div class="form-group row">
            <label class="col-sm-2 text-sm-right col-form-label">销量:</label>
            <span class="col-sm-3 col-form-label" th:text="*{buyCount}"></span>
            <label class="col-sm-2 text-sm-right col-form-label">浏览:</label>
            <span class="col-sm-3 col-form-label" th:text="*{viewCount}"></span>
        </div>
        <div class="form-group row">
            <label class="col-sm-2 text-sm-right col-form-label">状态:</label>
            <span class="col-sm-3 col-form-label " th:text="${book.isAvailable == 1?'上架':'下架'}"></span>

            <label class="col-sm-2 text-sm-right col-form-label">属性:</label>
            <div class="col-sm-2 pt-2">
                <label for="isElite">
                    <input type="checkbox" value="1" name="isElite" id="isElite"th:checked="*{isElite==1}" onchange="updateIsElite()"> 推荐
                </label>
                &nbsp;&nbsp;&nbsp;
                <label for="isTop">
                    <input type="checkbox" value="1" name="isTop" id="isTop" th:checked="*{isTop==1}" onchange="updateIsTop()"> 固顶
                </label>
            </div>
        </div>
        <div class="form-group row">
            <label class="col-sm-2 text-sm-right col-form-label">简介:</label>
            <span class="col-sm-8 col-form-label " th:text="${book.intro}"></span>
        </div>
    </form>
</div>
<th:block th:insert="~{include :: footer}" />
<th:block th:insert="~{include :: select2-js}" />
<th:block th:insert="~{include :: summernote-js}" />
<script>
    $(function () {
        var content = $("#noticeContent").val();
        $('#editor').html(content);
    });

    //固顶操作
    function updateIsTop() {
        var isTop = $("#isTop").prop("checked") ? 1 : 0;
        var str = "";
        if (isTop > 0) {
            str = "确定执行固顶操作"
        } else {
            str = "确定取消固顶操作"
        }
        $.modal.confirm(str, function () {
            var data = {"id": [[${book.id}]], "isTop": isTop};
            $.post("/book/update/top.json", data, function (json) {
                if (json.code === 0) {
                    location.reload()
                }
            })
        });
    }


    //推荐操作
    function updateIsElite() {
        var isElite = $("#isElite").prop("checked") ? 1 : 0;
        var str = "";
        if (isElite > 0) {
            str = "确定执行推荐操作"
        } else {
            str = "确定取消推荐操作"
        }
        $.modal.confirm(str, function () {
            var data = {"id": [[${book.id}]], "isElite": isElite};
            $.post("/book/update/elite.json", data, function (json) {
                if (json.code === 0) {
                    location.reload()
                }
            })
        });
    }
</script>
</body>
</html>